﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LogisticsManagementSystem.Truck
{
    public partial class EditTruck : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string id = Request.QueryString["id"];
                LogisticsModel.Truck truck = LogisticsBLL.TruckBLL.GetTruck(id);
                txtaccount.Value = truck.Number;
                oldpassword.Value = truck.Type;
                newpassword.Value = truck.Length;
                newpassword2.Value = truck.FK_TeamID.ToString();
                Password1.Value = truck.State.ToString();
                Password2.Value = truck.BuyDate.ToString();
                Password3.Value = truck.Remark.ToString();              
            }
        }

        protected void btnEdit_Click(object sender, EventArgs e)
        {
            int id = Convert.ToInt32(Request.QueryString["id"]);
            LogisticsModel.Truck truck = new LogisticsModel.Truck();
            truck.Number = txtaccount.Value;
            truck.Type = oldpassword.Value;
            truck.Length = newpassword.Value;
            truck.FK_TeamID =Convert.ToInt32(newpassword2.Value);
            truck.State = Convert.ToByte(Password1.Value);
            truck.BuyDate = Convert.ToDateTime(Password2.Value);
            truck.Remark = Password3.Value;
            truck.TruckID =id;

            if (LogisticsBLL.TruckBLL.EditTruck(truck))
            {
                Response.Write("<script>alert('修改成功')</script>");

            }
            else
            {
                Response.Write("<script>alert('修改失败')</script>");

            }
         
        }
    }
}